﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Quanly_Tour.DAL;
using System.Data;

namespace Quanly_Tour.BIZ
{
    class Diadiem_BIZ
    {
        private string Ma_DD;
        private string Ten_DD;
        private Quanly_DAL dal; 

        public string MA_DD1
        {
            get { return Ma_DD; }
            set { Ma_DD = value; }
        }        

        public string Ten_DD1
        {
            get { return Ten_DD; }
            set { Ten_DD = value; }
        }

        public Diadiem_BIZ()
        {
            Ma_DD = "";
            Ten_DD = "";
            dal = new Quanly_DAL();
        }

        public Diadiem_BIZ(string ma, string ten)
        {
            Ma_DD = ma;
            Ten_DD = ten;
            dal = new Quanly_DAL();
        }

        public DataTable LoadDS_DiaDiem()
        {            
            return dal.Select("DIADIEM");
        }

        public bool CheckExist()
        {
            DataTable dt = dal.Select("DIADIEM", "MA_DD='" + Ma_DD + "'");
            if (dt.Rows.Count > 0) return true;
            else return false;
        }

        public List<string> GetDD_ColName()
        {
            return dal.GetColumnName("DIADIEM");
        }

        public bool Add_DiaDiem()
        {
            if (Ma_DD == "" || Ten_DD == "") return false;
            else return dal.Insert("DIADIEM", new string[]{Ma_DD, Ten_DD});
        }

        public bool Edit_DiaDiem()
        {
            if (Ma_DD == "" || Ten_DD == "") return false;
            else return dal.Update("DIADIEM", new string[] { Ma_DD, Ten_DD });
        }

        public bool Remove_DiaDiem()
        {
            return dal.Delete("DIADIEM", "MA_DD='" + Ma_DD + "'");
        }

    }
}
